#include<iostream>
#include<algorithm>
#include<vector>

using std::vector;
using std::pair;
using std::make_pair;
using std::swap;
using std::cin;
using std::cout;

template<typename T>
void Input(vector<T> &first, vector<T> &second, vector<T> &res) {
    int size_first;
    cin >> size_first;
    first.resize(size_first);
    for (int i = 0; i < size_first; ++i) {
        cin >> first[i];
    }
    int size_second;
    cin >> size_second;
    second.resize(size_second);
    for (int i = 0; i < size_second; ++i) {
        cin >> second[i];
    }
    res.resize(size_first + size_second);
}

template<typename T>
void Split(pair <T, T> input1, pair<T, T> input2, T res)
{
    while (input1.first != input1.second && input2.first != input2.second) {
        if (*input1.first < *input2.first) {
            *res = *input1.first;
            ++res;
            ++input1.first;
        }
        else {
            *res = *input2.first;
            ++res;
            ++input2.first;
        }
    }
    while (input1.first != input1.second) {
        *res = *input1.first;
        ++res;
        ++input1.first;
    }

    while (input2.first != input2.second) {
        *res = *input2.first;
        ++res;
        ++input2.first;
    }
}

template<typename T>
void Output(const vector<T> &v) {
    for (auto elem : v) {
        cout << elem << " ";
    }
}
int main() {
    vector<int> first, second, res;

    Input(first, second, res);

    auto first_iterator = make_pair(first.begin(), first.end());
    auto second_iterator = make_pair(second.begin(), second.end());
    Split(first_iterator, second_iterator, res.begin());

    Output(res);
}